import { combineReducers } from 'redux'

import storageUtils from "../utils/storageUtils"
import { SET_HEAD_TITLE, SET_USER, RESET_USER } from './actions-types'

const initHeadTitle = ''
function headTitle (state = initHeadTitle, action) {
  const { type, data } = action
  switch (type) {
    case SET_HEAD_TITLE:
      return data
    default:
      return state
  }
}


const initUser = storageUtils.getUser()
function user (state = initUser, action) {
  const { type, data } = action
  switch (type) {
    case SET_USER:
      return data
    case RESET_USER:
      return {}
    default:
      return state
  }
}

export default combineReducers({
  headTitle,
  user
})